﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using SlimDX;
using SlimDX.Direct3D10;
using ColladaLoader;

namespace SCS.GFX {
  public abstract class MeshObject : Object {

    //private Mesh FMesh;
    public Vector3 FPosition; //mesh pos in collada file
    public Vector3 FOrientation;
    public Vector3 FLocation; //instance pos in world

    public Matrix FWorldMatrix; 
    public Matrix FObjectMatrix;

    public SlimDX.Direct3D10.Buffer FVertexBuffer;
    public SlimDX.Direct3D10.Buffer FIndexBuffer;

    public InputLayout FLayout;


    public Effect FEffect; //The actual shader (effect in DX)
    public EffectTechnique FTechnique; //The current technique from the shader we use
    public EffectPass FPass;      //The pass for the current technique
    public EffectVariable FEffectVariable; //A pointer to the shader, used to update the shaders constants

    // The variables below are used to update the shaders variables
    public EffectMatrixVariable FEffectViewProjectionMatrix; //A pointer to the shaders VIEWPROJECTION matrix
    public EffectMatrixVariable FEffectWorldMatrix;    //A pointer to the shaders World matrix


    public int FVerticeCount;
    public int FIndexCount;
    

    //Default constructor
    public MeshObject(MeshContainer m) : base() 
    {
    
    }

    public void SetPosition(Vector3 pos)
    {
        FLocation = pos;
    }

    public abstract void LoadTextures(MeshContainer m);

    public abstract void LoadVertexBuffer(MeshContainer m);

    public abstract void LoadIndexBuffer(MeshContainer m);

    public abstract void Render(RenderInfo aInfo);

    public virtual void Dispose() {

			if (FVertexBuffer != null)
				FVertexBuffer.Dispose();
			FVertexBuffer = null;
			if (FIndexBuffer != null)
				FIndexBuffer.Dispose();
			FIndexBuffer = null;


    }

  }
}
